<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <!-- 引入axios文件 -->
    <script src="./node_modules/axios/dist/axios.min.js"></script>
    <style>
        body {
            margin: 0;
            padding: 30px;
        }
    </style>
</head>

<body>
    <h1>添加用户</h1>
    用户名：<input type="text" id="username">
    密码：<input type="text" id="password">
    <button>提交</button>
    <script>
        document.querySelector("button").addEventListener("click", function () {
            const username = document.querySelector("#username").value;
            const password = document.querySelector("#password").value
            axios({
                method:'post',
                url:'http://localhost:3000/users',
                data:{username:username,password:password}
            }).then(res=>{
                location.href = './index.html'
            })
        })

    </script>
</body>

</html>